﻿<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <%

        string url = "http://www.qq.com";
            string htmlCode;
            System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
            webRequest.Timeout = 30000;
            webRequest.Method = "GET";
            webRequest.UserAgent = "Mozilla/4.0";
            webRequest.Headers.Add("Accept-Encoding", "gzip, deflate");
            System.Net.HttpWebResponse webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse();
            if (webResponse.ContentEncoding.ToLower() == "gzip")//如果使用了GZip则先解压
            {               
                using (System.IO.Stream streamReceive = webResponse.GetResponseStream())
                {
                    using (var zipStream =
                        new System.IO.Compression.GZipStream(streamReceive, System.IO.Compression.CompressionMode.Decompress))
                    {
                        using (System.IO.StreamReader sr = new System.IO.StreamReader(zipStream, Encoding.Default))
                        {
                            htmlCode = sr.ReadToEnd();
                        }
                    }
                }
            }
            else
            {
                using (System.IO.Stream streamReceive = webResponse.GetResponseStream())
                {
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(streamReceive, Encoding.Default))
                    {
                        htmlCode = sr.ReadToEnd();
                    }
                }
            }

            Response.Write(htmlCode);

        
         %>
    <div>
        <%
            //取得页面执行开始时间
            DateTime stime = DateTime.Now;

            Response.Write("ASP.NET3.5探针" + "<p>");
            Response.Write("[服务器端信息]" + "<p>");
            //服务器相关信息
            Response.Write("服务器名称：" + Server.MachineName + "<br>");
            Response.Write("服务器域名：" + Request.ServerVariables["SERVER_NAME"] + "<br>");
            Response.Write("服务器IP：" + Request.ServerVariables["LOCAL_ADDR"] + "<br>");
            Response.Write("HTTP端口：" + Request.ServerVariables["SERVER_PORT"] + "<br>");
            Response.Write("当前系统用户名：" + Environment.UserName + "<br />");
            Response.Write("服务器系统版本：" + Environment.OSVersion.ToString() + "<br>");
            Response.Write("服务器系统信息：" + Request.ServerVariables["HTTP_USER_AGENT"] + "<br>");
            Response.Write("服务器处理器个数：" + Environment.ProcessorCount.ToString() + "<br>");
            Response.Write("服务器物理内存：" + Environment.WorkingSet.ToString() + "<br>");
            Response.Write("启动到现在已运行：" + ((Environment.TickCount / 0x3e8) / 60).ToString() + "分钟" + "<br />");
            Response.Write("CPU 数量：" + Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS").ToString() + "<br />");
            Response.Write("CPU类型：" + Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").ToString() + "<br />");
            Response.Write("服务端语言：" + Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"] + "<br>");
            Response.Write("Framework版本：" + Environment.Version.ToString() + "<br>");
            Response.Write("服务器时间：" + DateTime.Now + "<br>");
            //Response.Write("Framework版本：" + string.Concat(new object[] { Environment.Version.Major, ".", Environment.Version.Minor, Environment.Version.Build, ".", Environment.Version.Revision }) + "<br />");
            Response.Write("ASP.NET所站内存：" + ((Double)System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + "M" + "<br />");
            try{Response.Write("ASP.NET所占CPU：" + ((TimeSpan)System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString("N0") + "%<br />");}
            catch { }
            
            //文件路径
            Response.Write("探针文件路径：" + Server.MapPath(Request.ServerVariables["SCRIPT_NAME"]) + "<br>");
            Response.Write("服务器系统所在文件夹：" + Environment.SystemDirectory.ToString() + "<br>");
            Response.Write("允许文件：" + Request.ServerVariables["HTTP_ACCEPT"] + "<br>");
            Response.Write("MD目录：" + Request.ServerVariables["APPL_MD_PATH"] + "<br>");
            Response.Write("执行文件绝对路径：" + Request.ServerVariables["PATH_TRANSLATED"] + "<br />");
            Response.Write("虚拟目录绝对路径：" + Request.ServerVariables["APPL_PHYSICAL_PATH"] + "<br />");
            //
            Response.Write("虚拟目录Session总数：" + Session.Contents.Count + "<br />");
            Response.Write("虚拟目录Application总数：" + Application.Contents.Count + "<br />");
            //
            Response.Write("IIS版本：" + Request.ServerVariables["SERVER_SOFTWARE"] + "<br>");
            Response.Write("脚本超时时间：" + (Server.ScriptTimeout / 1000).ToString() + "秒" + "<br>");
            Response.Write("SLL连接：" + Request.ServerVariables["HTTPS"] + "<br>");
            Response.Write("CGI版本：" + Request.ServerVariables["GATEWAY_INTERFACE"] + "<br>");
            //IE版本
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Version Vector");
            Response.Write("IE版本：" + key.GetValue("IE", "未检测到").ToString() + "<br />");
            //逻辑驱动器
            Response.Write("逻辑驱动器：");
            string[] achDrives = System.IO.Directory.GetLogicalDrives();
            foreach (string dir in System.IO.Directory.GetLogicalDrives())
            {
                Response.Write(dir);
            }
            Response.Write("<p />");

            //客户端信息
            Response.Write("[客户端信息]" + "<p>");

            //客户端信息
            Response.Write("客户端ip地址：" + Request.ServerVariables["REMOTE_ADDR"] + "<br>");
            Response.Write("客户端浏览器类型：" + Request.Browser.Type + "<br>");
            Response.Write("客户端浏览器类型：" + Request.Browser + "<br>");
            Response.Write("客户端浏览器版本：" + Request.Browser.Version + "<br>");
            Response.Write("客户端浏览器主版本：" + Request.Browser.MajorVersion + "<br>");
            Response.Write("客户端浏览器次版本：" + Request.Browser.MinorVersion + "<br>");
            Response.Write("客户端浏览器是否测试版本：" + Request.Browser.Beta + "<br>");
            Response.Write("客户端浏览器是否客户平台：" + Request.Browser.Platform + "<br>");
            Response.Write("客户端浏览器是否AOL 浏览器：" + Request.Browser.AOL + "<br>");
            Response.Write("客户端浏览器是否基于Win16：" + Request.Browser.Win16 + "<br>");
            Response.Write("客户端浏览器是否基于Win32：" + Request.Browser.Win32 + "<br>");
            Response.Write("客户端浏览器是否支持框架：" + Request.Browser.Frames + "<br>");
            Response.Write("客户端浏览器是否支持表格：" + Request.Browser.Tables + "<br>");
            Response.Write("客户端浏览器是否支持Cookies：" + Request.Browser.Cookies + "<br>");
            Response.Write("客户端浏览器是否支持VB Script：" + Request.Browser.VBScript + "<br>");
            Response.Write("客户端浏览器是否支持JavaScript：" + Request.Browser.JavaScript + "<br>");
            Response.Write("客户端浏览器支持JScript的版本：" + Request.Browser.JScriptVersion + "<br>");
            Response.Write("客户端浏览器是否支持JavaApplets：" + Request.Browser.JavaApplets + "<br>");
            Response.Write("客户端浏览器是否支持ActiveXControls：" + Request.Browser.ActiveXControls + "<br>");
            Response.Write("客户端浏览器是否支持CDF：" + Request.Browser.CDF + "<br>");
            Response.Write("客户端浏览器是否支持背景音乐：" + Request.Browser.BackgroundSounds + "<br>");
            Response.Write("客户端浏览器ECMAScript版本：" + Request.Browser.EcmaScriptVersion + "<br>");
            Response.Write("客户端浏览器MSDom版本：" + Request.Browser.MSDomVersion + "<br>");
            Response.Write("客户端浏览器W3CDom版本：" + Request.Browser.W3CDomVersion + "<br>");
            Response.Write("客户端浏览器语言：" + Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"] + "<p>");

            //取得页面执行结束时间
            DateTime etime = DateTime.Now;
            //计算页面执行时间
            Response.Write("本次页面执行时间: " + ((etime - stime).TotalMilliseconds).ToString() + "毫秒" + "<br>");
        %>
    </div>
    </form>
</body>
</html>
